package com.yun.zhong.fu.sharecenter.sentinel;

import com.alibaba.csp.sentinel.adapter.servlet.callback.RequestOriginParser;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author RenPu
 * @Date 2020/12/30 16:51
 * @Version 1.0
 * @Description: 实现sentinel的分区访问
 **/

@Component
public class MyRequestOriginParser implements RequestOriginParser {
    @Override
    public String parseOrigin(HttpServletRequest httpServletRequest) {

        String parameter = httpServletRequest.getParameter("origin");

        if (StringUtils.isNotBlank(parameter)) {
            throw new IllegalArgumentException("origin must  be required");

        }


        return parameter;
    }
}
